package zxs.sino.elite.hub.controller;

import java.util.Arrays;
import java.util.Map;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zxs.sino.elite.hub.model.app.ArticleLikesEntity;
import zxs.sino.elite.hub.service.app.ArticleLikesService;
import zxs.sino.elite.hub.utils.PageUtil;
import zxs.sino.elite.hub.utils.R;



/**
 * 文章点赞表
 *
 * @author zhang
 * @email 15824760766@163.com
 * @date 2025-09-02 20:23:52
 */
@RestController
@RequestMapping("articlelikes")
@RequiredArgsConstructor
public class ArticleLikesController {

    private final  ArticleLikesService articleLikesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtil page = articleLikesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{articleLikeId}")
    public R info(@PathVariable("articleLikeId") Long articleLikeId){
		ArticleLikesEntity articleLikes = articleLikesService.getById(articleLikeId);

        return R.ok().put("articleLikes", articleLikes);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ArticleLikesEntity articleLikes){
		articleLikesService.save(articleLikes);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ArticleLikesEntity articleLikes){
		articleLikesService.updateById(articleLikes);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] articleLikeIds){
		articleLikesService.removeByIds(Arrays.asList(articleLikeIds));

        return R.ok();
    }

}
